<?php

use common\components\helpers\Fun;
use common\components\extenders\MenuManage;

?>
<div class="docs-main">
    <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check">
        <thead>
        <tr class="yx-bgd2f6ec">
            <td>课程名称</td>
            <td>上课日期</td>
            <td>上课时间</td>
            <td>课次</td>
            <td>状态</td>
            <td>操作</td>
        </tr>
        </thead>
        <?php foreach ($details as $i => $v) { ?>
            <tr>
                <td><?= \yii\helpers\Html::encode($v->title) ?></td>
                <td><?= \Yii::$app->formatter->asDate($v->class_date) ?></td>
                <td><?= \common\components\helpers\Fun::getClassTime($v->start_time, $v->end_time) ?></td>
                <td><?= \yii\helpers\Html::encode($v->lesson) ?></td>
                <td><?php if ($v->status == 0) {
                        echo '未上课';
                    } elseif ($v->status == 1) {
                        echo '已上课';
                    } elseif ($v->status == 2) {
                        echo '教师请假';
                    } elseif ($v->status == 3) {
                        echo '学生请假';
                    } elseif ($v->status == 4) {
                        echo '教师停课';
                    } elseif ($v->status == 5) {
                        echo '代课';
                    } elseif ($v->status == 6) {
                        echo '复课';
                    } ?></td>
                <td>
                    <?php if ($v->status == 0): ?>
                        <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage', 'status', true, ['class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2', 'id' => "lesson$i", 'data' => ['lesson_id' => $v['lesson_id']]]); ?>
                    <?php else: ?>
                        <button style="color:#ffffff;border: none;padding: 1px 12px;border-radius:2px" type="button">
                            修改状态
                        </button>
                    <?php endif; ?>
                    <?php if (isset(\Yii::$app->user->identity->role) && \Yii::$app->user->identity->role == 'admin'): ?>
                        <?php if ($v->status == 0): ?>
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage', 'updateclasstime', true, ['class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2', 'data' => ['id' => $v['lesson_id']]]); ?>
                        <?php else: ?>
                            <button style="color:#ffffff;border: none;padding: 1px 12px;border-radius:2px"
                                    type="button">修改上课时间
                            </button>
                        <?php endif; ?>
                    <?php endif; ?>
                </td>
            </tr>
        <?php } ?>
    </table>
</div>